<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
        var num=prompt("请输入菱形上半部分的行数：","");
        for (var i=1;i<=num;i++){
            document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
            for (var k=num;k>=i;k--){
                document.writeln("&nbsp;");
            }
            for (var j=1;j<=2*i-1;j++){
                if(j%2==0){
                    document.writeln("&nbsp;");
                }else{
                    document.writeln("*");
                }
            }
            document.write("<br/>");
        }
        for (var i=num-1;i>=1;i--){
            document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
            for (var k=num;k>=i;k--){
                document.writeln("&nbsp;");
            }
            for (var j=1;j<=2*i-1;j++){
                if(j%2==0){
                    document.writeln("&nbsp;");
                }else{
                    document.writeln("*");
                }
            }
            document.write("<br/>");
        }
    </script>

</body>
</html>